package net.wenku8.reader.view.rank

import androidx.compose.runtime.mutableStateOf
import androidx.navigation.NavController
import net.wenku8.reader.enums.RouteRankDetail
import net.wenku8.reader.enums.RouteSearch
import net.wenku8.reader.state.StateLogin
import net.wenku8.reader.state.StateRank
import net.wenku8.reader.state.StateSearch
import net.wenku8.reader.view.common.BaseViewModel

class RankListViewModel : BaseViewModel() {

    val key = mutableStateOf("")
    val rankMap = mapOf(
        "postdate" to "最新入库",
        "goodnum" to "总收藏量排行",
        "fullflag" to "完结小说列表",
        "lastupdate" to "最近更新",
        "allvisit" to "总点击排行",
        "allvote" to "总推荐排行",
        "monthvisit" to "月点击排行",
        "monthvote" to "月推荐排行",
        "weekvisit" to "周点击排行",
        "weekvote" to "周推荐排行",
        "dayvisit" to "日点击排行",
        "dayvote" to "日推荐排行",
        "size" to "字数排行",
    )

    fun toSearch(navController : NavController, type : String){
        if (!StateLogin.status.value){
            showSnackbar("请先登陆")
            return
        }
        StateSearch.type.value = type
        StateSearch.key.value = key.value
        navController.navigate(RouteSearch)
    }

    fun toRankDetail(navController : NavController, type : String, title : String){
        if (!StateLogin.status.value){
            showSnackbar("请先登陆")
            return
        }
        StateRank.type.value = type
        StateRank.title.value = title
        navController.navigate(RouteRankDetail)
    }

}